﻿using System;
using Icms.Core.Model;
using Icms.Core.Repository;
using Icms.WebUI.Dto;

namespace Icms.WebUI.Builder
{
    public class HearingMapper : Mapper<Hearing, HearingInput>
    {
        public HearingMapper(IReadRepo<Hearing> repo)
            : base(repo)
        {
        }

        protected override void MakeInput(Hearing entity, ref HearingInput input)
        {
            input.Hour = entity.Date.Hour;
            input.Minute = entity.Date.Minute;
            input.DurationHours = entity.Duration / 60;
            input.DurationMinutes = entity.Duration % 60;
        }

        protected override void MakeEntity(ref Hearing entity, HearingInput input)
        {
            entity.Duration = input.DurationHours * 60 + input.DurationMinutes;
            entity.Date = new DateTime(entity.Date.Year, entity.Date.Month, entity.Date.Day, input.Hour, input.Minute, 0);
        }
    }

   

    
}